package com.trkj.controllers;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.trkj.pojos.Card;
import com.trkj.pojos.ChargeprojectTable;
import com.trkj.service.Card_service;
import com.trkj.vo.Serach_condition;

@Controller
public class Card_controller {
	@Autowired
	Card_service card_service;
	/**
	 * 验证用户今天是否可以继续办卡
	 * @param card
	 * @return
	 * @throws ParseException 
	 */
	@RequestMapping("vertifyApplyCard")
	@ResponseBody
	public String vertifyApplyCard(Card card) throws ParseException{
		String result=card_service.vertifyApplyCard(card);
		return result;
	}
	/**
	 * 生成新卡
	 * @param card
	 * @return
	 */
	@RequestMapping("applyCard")
	@ResponseBody
	public String applyCard(String cradId,String project_id,Double project_cost){
		return card_service.applyCard(cradId,project_id,project_cost);
	}
	/**
	 * 加载诊疗卡收费页面
	 * @return
	 */
	@RequestMapping("to_charge_apply_card")
	public ModelAndView to_charge_apply_card(ModelAndView mv){
		mv.addObject("project", card_service.get_card_project());
		mv.setViewName("charge_apply_card");
		return mv;
	}
	
	
	/**
	 * 多条件分页查询诊疗卡
	 * @return
	 */
	@RequestMapping("checkAllCard")
	@ResponseBody
	public Map<String,Object> checkAllCard(Serach_condition card){
		System.out.println(card);
		return card_service.checkAllCard(card);
	}
	
	/**
	 * 加载诊疗卡详情子页面
	 * @return
	 */
	@RequestMapping("to_card_detail")
	public String to_card_detail(){
		return "card_detail";
	}
	
	/**
	 * 修改诊疗卡信息
	 * @param card
	 * @return
	 */
	@RequestMapping("save_change_card_detail")
	@ResponseBody
	public String save_change_card_detail(Card card){
		return card_service.save_change_card_detail(card);
	}
	
	/**
	 * 挂失诊疗卡
	 * @param card_id
	 * @return
	 */
	@RequestMapping("set_card_lost")
	@ResponseBody
	public String set_card_lost(String card_id){
		return card_service.set_card_lost(card_id);
	}
	
	@RequestMapping("test2")
	public String to_test2(){
		return "test2";
	}
}
